package cn.com.web.Servlet;

import cn.com.service.OrderService;
import cn.com.service.RoomService;
import cn.com.service.impl.OrderServiceImpl;
import cn.com.service.impl.RoomServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/DeleteOrderServlet")
public class DeleteOrderServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.获取所有id
        String[] ouids = request.getParameterValues("ouid");
        //2.调用service删除
        OrderService service=new OrderServiceImpl();
        //如果没传参数
        if ( ouids==null || ouids.length<1 ){
            String ouidd=request.getParameter("ouid");
            if (ouidd == null)
            {
                request.getRequestDispatcher("FindRoomByPageServlet?currentPage=1&rows=5")
                        .forward(request,response);
                return;
            }
            service.delteOrderbyid(ouidd);
        }else for (String ouid : ouids) {
            service.delteOrderbyid(ouid);
        }
        //请求转发到ShowCustomerServlet
        request.getRequestDispatcher("FindOrderByPageServlet?currentPage=1&rows=5").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
